﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace GameWP
{
    public class Aura : VisibleGame
    {
#region Properties
        protected int _indexTexture;
        public int IndexTexture
        {
            get { return _indexTexture; }
            set { _indexTexture = value; }
        }

        protected List<Texture2D> _listTexture;
        public List<Texture2D> ListTexture
        {
          get { return _listTexture; }
          set { _listTexture = value; }
        }

        protected Vector2 _position;
        public Vector2 Position
        {
          get { return _position; }
          set { _position = value; }
        }

        protected Vector2 _initPosition;
        public Vector2 InitPosition
        {
          get { return _initPosition; }
          set { _initPosition = value; }
        }

        protected Color _colorTexture;
        public Color ColorTexture
        {
          get { return _colorTexture; }
          set { _colorTexture = value; }
        }

        protected float _scaleTexture;
        public float ScaleTexture
        {
          get { return _scaleTexture; }
          set { _scaleTexture = value; }
        }
#endregion

#region Initlation
        public Aura(List<Texture2D> listTexture, Vector2 initPosition)
        {
            _listTexture = listTexture;
            _initPosition = initPosition;
            _position = _initPosition;
            _indexTexture = -1;
            _colorTexture = Color.White;
            _scaleTexture = 1f;
        }
#endregion

#region Method
        public void StartAura()
        {
            _indexTexture = 0;
        }
        public void StartAura(Vector2 position)
        {
            _position = position;
            _indexTexture = 0;
        }
#endregion

#region Update & Draw
        public void Update(GameTime gametime)                     
        {
            if (_indexTexture > -1)
            {
                _indexTexture++;
                if (_indexTexture >= _listTexture.Count)
                {
                    _indexTexture = -1;
                    _position = _initPosition;
                }
            }
        }

        public void Draw(SpriteBatch spritebatch, GameTime gametime)
        {
            if (_indexTexture > -1)
                spritebatch.Draw(_listTexture[_indexTexture], _position, null, _colorTexture, 0, Vector2.Zero, _scaleTexture,SpriteEffects.None, 0);
        }
    #endregion
    }
}
